<template>
	<view class="main-view">
		<!-- <text>欢迎您,{{userId}}</text> -->
		<!-- <button @click="newEnroll">发起新报名</button>
		<button @click="personInfo">个人信息</button>
		<button @click="templetMain">管理模板</button>
		<view><input placeholder="报名id" v-model="eId"/><button @click="enrollFill">前往报名</button></view>
		<button @click="filledEnroll">参与过的报名</button>
		<button @click="launchedEnroll">发起过的报名</button> -->
		
		
		<view class="enroll-item dashboard"  @click="enrollResult(enrollData.eId)" v-for="enrollData in enrollDatas" :key="enrollData.submitTime">
			<view class="enroll-title">{{enrollData.title}}</view>
			<view class="enroll-time">提交时间：{{formatDatetime.formatDatetime(new Date(enrollData.submitTime))}}</view>
			<view class="check-time" v-if="enrollData.status!=0">审核时间：{{formatDatetime.formatDatetime(new Date(enrollData.checkTime))}}</view>

			<view class="enroll-status" v-bind:style="{color:(enrollData.status==0?'rgb(168, 180, 77)':(enrollData.status==1?'green':'red'))}">{{enrollDataStatusTran(enrollData.status)}}</view>
		</view>
		<button @click="more" type="primary" style="width:80%;margin-top:20upx;">加载更多</button>
	</view>
</template>
	
	

<script>
	import formatDatetime from "../../common/zdateutil.js"
	import tranUtil from "../../common/znumtranutil.js"
	export default {
		
		data() {
			return {
				enrollDatas : [],
				formatDatetime : null,
				enrollDataStatusTran : null
			}
		},
		onLoad : function() {
			// console.log(formatDatetime.formatDatetime)
			this.enrollDataStatusTran = tranUtil.tranUtil.enrollDataStatusTran;
			this.formatDatetime = formatDatetime;
			var token;
			var vm = this;
			// 载入用户id
			uni.getStorage({
				key : 'userToken',
				success :function(res){
					token = res.data;
					vm.userId = token.userId;
					
					var param = {'length':10,'lastTimeLong':new Date().getTime()}
					vm.$get(vm.enrollurl + '/enroll/moreEnrollData',param,function(res){
						var data = res.data;
						if(data.code != 0){
							// vm.errorText = data.message;
							return;
						}
						// console.log(data.object)
						vm.enrollDatas = data.object;
						console.log(vm.enrollDatas)
					});
				},
				fail : function(){
					uni.navigateTo({
						url : 'index'
					})
				}
			});
			
		},
		methods: {
			more : function(){
				var vm = this;
				var param = {'length':10,'lastTimeLong':this.enrollDatas[this.enrollDatas.length - 1].submitTime}
				this.$get(this.enrollurl + '/enroll/moreEnrollData',param,function(res){
					var data = res.data;
					if(data.code != 0){
						// vm.errorText = data.message;
						return;
					}
					vm.enrollDatas = vm.enrollDatas.concat(data.object);
				});
			},
			enrollResult : function(eId){
				uni.navigateTo({
					url : './enrollResult?eId=' + eId
				})
			}
			
		}
	}
</script>

<style>
	@import "../../common/zcss.css";
	.main-view{
		width: 100%;
		flex-direction: column;
	}
	.enroll-item{
		border: 1upx solid gray;
		height: 150upx;
		position: relative;
		width: 99%;
		margin-bottom: 3upx;
		/* background-color: white; */
		/* background-color: azure; */
	}
	/* .enroll-button{
		position: absolute;
		font-size:40upx;
		height:80upx;
		width: 160upx;
		right: 1%;
	} */
	.enroll-time{
		position: absolute;
		font-size: 20upx;
		color: gray;
		left: 1%;
		bottom: 0%;
	}
	.check-time{
		position: absolute;
		font-size: 20upx;
		color: gray;
		right: 1%;
		bottom: 0%;
	}
	.enroll-status{
		position: absolute;
		font-size: 20upx;
		right: 1%;
		bottom: 30upx;;
	}
	.enroll-title{
		font-size: 50upx;
		position: absolute;
		top: 1%;
		left: 1%;
	}
</style>
